import { createRouter, createWebHistory } from "vue-router";
const layout = import("@/views/layout/index.vue");
const constantRoutes = [
  {
    path: "/",
    name: "home",
    meta: { title: "首页" },
    component: () => import("@/views/layout/index.vue"),
  },
  {
    path: "/login",
    name: "login",
    meta: { title: "登录" },
    component: () => import("@/views/login/index.vue"),
  },
  {
    path: "/403",
    name: "no-permission",
    meta: { title: "页面飞走了" },
    component: () => import("@/views/error/403.vue"),
  },
  {
    path: "/500",
    name: "error",
    meta: { title: "服务器异常" },
    component: () => import("@/views/error/403.vue"),
  },
];
export const asyncRoutes = [
  {
    path: "/house",
    name: "house",
    meta: { title: "房屋" },
    component: layout,
    children: [
      {
        path: "list",
        name: "house-list",
        meta: { title: "房屋列表" },
        component: () => import("@/views/house/house-list.vue"),
      },
      {
        path: "manage",
        name: "house-manage",
        meta: { title: "房屋管理" },
        component: () => import("@/views/house/house-manage.vue"),
      },
    ],
  },
  {
    path: "/user",
    name: "user",
    meta: { title: "用户" },
    component: () => import("@/views/user/index.vue"),
    children: [
      {
        path: "list",
        name: "user-list",
        meta: { title: "用户列表" },
        component: () => import("@/views/user/user-list.vue"),
      },
      {
        path: "info",
        name: "user-info",
        meta: { title: "个人信息" },
        component: () => import("@/views/user/user-list.vue"),
      },
    ],
  },
];
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: constantRoutes,
});
// router.beforeEach((to, from, next) => {});
export default router;
